﻿//=============================================================
// Copyright (C) 2011 深圳市中旭企业管理股份有限公司
// 作 者：孙德响
// 日 期：2011-11-14
// 描 述: 心得管理LIST
// 版 本：1.00
// 修改历史纪录
// 版 本  修改时间      修改人            修改内容
// 1.00   2011/10/11   孙德响          
//=============================================================

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZX.Common;
using ZX.BLL;
using ZX.DBModule;
using System.Text.RegularExpressions;
using System.Text;

using ZX.Web.UI.Controls;
using ZX.BLL.Extend;

namespace ZX.WebApp.TR
{
    /// <summary>
    /// 心得管理LIST
    /// </summary>
    public partial class GainShareList : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string strEntity = this.GetStringFromQueryString("entity", "E_Menu");
            string strCondition = this.GetStringFromQueryString("condition", "");
            int iPageIndex = this.GetIntFromQueryString("pageindex", 0);
            int iPageSize = this.GetIntFromQueryString("pagesize", 0);
            strCondition = Server.UrlDecode(strCondition);
            string strType = this.GetStringFromQueryString("type", "");
            string strOrder = this.GetStringFromQueryString("order", "");
            strEntity = strEntity.Split(',')[0];
            BaseEntity entity = ZX.Common.Reflection.CreateEntitysInstance(strEntity) as BaseEntity;
            if (entity == null)
            {
                entity = ZX.Common.Reflection.CreateEntitysInstance(strEntity) as BaseEntity;
            }
            BaseBussnies<BaseEntity> bll = new BaseBussnies<BaseEntity>(entity);
            bll.PageIndex = iPageIndex;
            bll.PageSize = iPageSize;
            bll.Order = strOrder;
            IList<BaseEntity> list = string.IsNullOrEmpty(strCondition) ? bll.GetEntitysByCondition("1=1") : bll.GetEntitysByCondition(strCondition);
            if (list == null)
            {
                HttpContext.Current.Response.Write("[{\"N\":\"null\"}]");
                return;
            }
            string strFormat = "{\"total\":" + list.Count().ToString() + ",\"rows\":[";
            string str = list.ToJSON().Replace("\n", "@@@@").Replace("\r", "@@@@").Replace("null", "");
            strFormat = strFormat + str + "]}";
            //strFormat = strFormat.Replace(new Regex("(^|[^\\\\])\\\"\\\\/Date\\((-?[0-9]+)\\)\\\\/\\\"","$1new Date($2)");
            if (strType == "1")
            {
                HttpContext.Current.Response.Write("[" + str.Replace("null", "").Replace("[A]", "&") + "]");
            }
            else
            {
                HttpContext.Current.Response.Write(strFormat);
            }
        }
    }
}